package guda.house.biz.form.bill;

import guda.house.dal.dataobject.BillElecDO;

import javax.validation.constraints.NotNull;
import java.text.SimpleDateFormat;

/**
 * Created by well on 15/11/15.
 */
public class BillElecEditForm extends BillElecForm{

    @NotNull(message = "不能为空")
    private Long billId;

    public Long getBillId() {
        return billId;
    }

    public void setBillId(Long billId) {
        this.billId = billId;
    }

    public BillElecDO toDO(){
        BillElecDO billElecDO = super.toDO();
        billElecDO.setBillId(billId);
        return billElecDO;
    }

    public void initForm(BillElecDO billElecDO){
        setBillId(billElecDO.getBillId());
        setRecordCurrent(billElecDO.getRecordCurrent());
        setIsPayed(billElecDO.getIsPayed());
        setRecordLast(billElecDO.getRecordLast());
        setRecordCurrent(billElecDO.getRecordCurrent());
        setRecordYear(billElecDO.getRecordYear());
        setRecordMonth(billElecDO.getRecordMonth());
        if(billElecDO.getGmtEnd()!=null) {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            setGmtEnd(simpleDateFormat.format(billElecDO.getGmtEnd()));
        }
        if(billElecDO.getGmtStart()!=null) {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            setGmtStart(simpleDateFormat.format(billElecDO.getGmtStart()));
        }
        if(billElecDO.getGmtRecord()!=null) {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
            setGmtRecord(simpleDateFormat.format(billElecDO.getGmtRecord()));
        }
    }
}
